using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BBCoder {
	public struct InputBoxResult {
		public DialogResult result;
		public string text;
	}

	public class InputBox {
		public static InputBoxResult ShowDialog(string message, string defaultText, string title) {
			InputBoxDialog ib = new InputBoxDialog();
			InputBoxResult ibr;

			ib.lblMessage.Text = message;
			ib.txtInput.Text = defaultText;
			ib.Text = title;

			ibr.result = ib.ShowDialog();
			ibr.text = ib.txtInput.Text;

			return ibr;
		}

		private class InputBoxDialog: Form {

			/// <summary>
			/// Required designer variable.
			/// </summary>
			private System.ComponentModel.IContainer components = null;

			/// <summary>
			/// Clean up any resources being used.
			/// </summary>
			/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
			protected override void Dispose(bool disposing) {
				if(disposing && (components != null)) {
					components.Dispose();
				}
				base.Dispose(disposing);
			}

			#region Windows Form Designer generated code

			/// <summary>
			/// Required method for Designer support - do not modify
			/// the contents of this method with the code editor.
			/// </summary>
			private void InitializeComponent() {
				this.lblMessage = new System.Windows.Forms.Label();
				this.txtInput = new System.Windows.Forms.TextBox();
				this.btnCancel = new System.Windows.Forms.Button();
				this.btnOK = new System.Windows.Forms.Button();
				this.SuspendLayout();
				// 
				// lblMessage
				// 
				this.lblMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
										| System.Windows.Forms.AnchorStyles.Left)
										| System.Windows.Forms.AnchorStyles.Right)));
				this.lblMessage.Location = new System.Drawing.Point(12, 9);
				this.lblMessage.Name = "lblMessage";
				this.lblMessage.Size = new System.Drawing.Size(261, 31);
				this.lblMessage.TabIndex = 0;
				this.lblMessage.Text = "Message goes here";
				// 
				// txtInput
				// 
				this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
										| System.Windows.Forms.AnchorStyles.Right)));
				this.txtInput.Location = new System.Drawing.Point(12, 43);
				this.txtInput.Name = "txtInput";
				this.txtInput.Size = new System.Drawing.Size(261, 22);
				this.txtInput.TabIndex = 2;
				// 
				// btnCancel
				// 
				this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
				this.btnCancel.Location = new System.Drawing.Point(203, 71);
				this.btnCancel.Name = "btnCancel";
				this.btnCancel.Size = new System.Drawing.Size(70, 24);
				this.btnCancel.TabIndex = 3;
				this.btnCancel.Text = "&Cancel";
				this.btnCancel.UseVisualStyleBackColor = true;
				this.btnCancel.DialogResult = DialogResult.Cancel;
				// 
				// btnOK
				// 
				this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
				this.btnOK.Location = new System.Drawing.Point(125, 71);
				this.btnOK.Name = "btnOK";
				this.btnOK.Size = new System.Drawing.Size(72, 24);
				this.btnOK.TabIndex = 4;
				this.btnOK.Text = "&OK";
				this.btnOK.UseVisualStyleBackColor = true;
				this.btnOK.DialogResult = DialogResult.OK;
				// 
				// InputBox
				// 
				this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
				this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
				this.ClientSize = new System.Drawing.Size(285, 107);
				this.Controls.Add(this.btnCancel);
				this.Controls.Add(this.btnOK);
				this.Controls.Add(this.txtInput);
				this.Controls.Add(this.lblMessage);
				this.Font = new System.Drawing.Font("Tahoma", 9F);
				this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
				this.MaximizeBox = false;
				this.MinimizeBox = false;
				this.Name = "InputBox";
				this.ShowInTaskbar = false;
				this.Text = "InputBox";

				this.CancelButton = btnCancel;
				this.AcceptButton = btnOK;

				this.ResumeLayout(false);
				this.PerformLayout();
			}

			#endregion

			public System.Windows.Forms.Label lblMessage;
			public System.Windows.Forms.TextBox txtInput;
			private System.Windows.Forms.Button btnCancel;
			private System.Windows.Forms.Button btnOK;

			public InputBoxDialog() {
				InitializeComponent();
			}
		}
	}
}